package cn.com.qiter.minioservice.config;

import cn.com.qiter.minioservice.utils.ConstantPropertiesUtils;
import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Data
@Component
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {

    private String endpoint;
    private String accessKey;
    private String secretKey;

    @Bean
    public MinioClient getMinioClient() throws InvalidEndpointException, InvalidPortException {
        MinioClient minioClient = new MinioClient(ConstantPropertiesUtils.END_POIND, ConstantPropertiesUtils.ACCESS_KEY_SECRET, ConstantPropertiesUtils.ACCESS_KEY_ID);
        return minioClient;
    }

}
